﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Reflection;
using System.Text;

namespace Common.Framework.Core.Extension
{
    /// <summary>
    /// Enum扩展
    /// </summary>
    public static class EnumExtension
    {
        /// <summary>
        /// 获取EnumDiscription
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static string GetEnumDiscriptionExtension(System.Enum value)
        {

            var ret = string.Empty;
            var enumType = value.GetType();
            var fileds = enumType.GetField(value.ToString());
            if (fileds.IsDefined(typeof(DescriptionAttribute), false))
            {
                var des = (DescriptionAttribute)fileds.GetCustomAttribute(typeof(DescriptionAttribute), false);
                return des.Description;
            }
            return ret;
        }
    }
}
